﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace projekt_planet_express_doerr
{
    class ClockTimer
    {
        private int endTimer;
        private int countTimerRef;
        public String displayClock { get; private set; }
        public bool isRunning { get; private set; }
        public bool isFinished { get; private set; }

        public ClockTimer()
        {

            displayClock = "";
            endTimer = 0;
            countTimerRef = 0;
            isRunning = false;
            isFinished = false;

        }

        public void start(int seconds)
        {
            endTimer = seconds;
            isRunning = true;
            displayClock = endTimer.ToString();
        }

        public Boolean checkTime(GameTime gameTime)
        {
            countTimerRef += (int)gameTime.ElapsedGameTime.TotalMilliseconds;
            if (!isFinished)
            {
                if (countTimerRef >= 1000.0f)
                {
                    endTimer = endTimer - 1;
                    displayClock = endTimer.ToString();
                    countTimerRef = 0;
                    if (endTimer <= 0)
                    {
                        endTimer = 0;
                        isFinished = true;
                        displayClock = "Game Over";

                    }
                }
            }
            else
            {

                displayClock = "Game Over";

            }
            return isFinished;
        }
    }
}
